<include file="public@header"/>
</head>
<block name="header">
</block>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>{$title}</legend>
</fieldset>
<block name="top_content">
</block>
<div class="wrap js-check-wrap">
    <form class="layui-form" action="{$submitUrl}"  method="post" class="form-horizontal js-ajax-form margin-top-20">
        <foreach name="formData" item="dataItem" key="formkey">
            <switch name="dataItem.2">
                <case value="date_day">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input"
                                   id="{$dataItem[0]}"
                                   {if condition=" !isset($dataItem['readonly'])  "}  name="{$dataItem[0]}"  {/if}
                            {if condition=" isset($dataItem['readonly'])  "}  readonly disabled="disabled"  {/if}
                            lay-verify="date" placeholder="{$dataItem[0]}" autocomplete=""
                            value="{$dataItem[3]}"
                            class="layui-input" onclick="layui.laydate({elem: this, format: 'YYYY-MM-DD',istime: false})">
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                    </div>
                </case>
                <case value="date_second">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input"
                                   {if condition=" !isset($dataItem['readonly'])  "}  name="{$dataItem[0]}"  {/if}
                            {if condition=" isset($dataItem['readonly'])  "}  readonly disabled="disabled"  {/if}
                            id="{$dataItem[0]}"
                            placeholder="{$dataItem[0]}" autocomplete=""
                            value="{$dataItem[3]}"
                            class="layui-input" onclick="layui.laydate({elem: this, format: 'YYYY-MM-DD hh:mm:ss',istime: true})">
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                    </div>
                </case>
                <case value="checkbox_tree">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-block">
                            <div id="{$dataItem[0]}"></div>
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[5]}</div>
                    </div>
                </case>
                <case value="checkbox">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-block">
                            <foreach name ="dataItem.3" item ="val" key="key" >
                                <input type="checkbox"
                                <if condition=" !isset($dataItem['readonly'])  ">  name="{$dataItem[0]}[]"  </if>
                                <if condition=" isset($dataItem['readonly'])  ">  readonly disabled="disabled"  </if>
                                <if condition="$val eq $dataItem[4]"> checked="" </if>
                                <in name="$val" value="$dataItem[4]"> checked="" </in>
                                value="{$val}" title="{$key}">
                            </foreach>
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[5]}</div>
                    </div>
                </case>
                <case value="checkbox_origin">
                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-block">
                            {foreach $dataItem[3] as $key=>$val }
                            <input type="checkbox" lay-skin="primary"
                                   {if condition=" !isset($dataItem['readonly'])  "}  name="{$dataItem[0]}[]"  {/if}
                            {if condition=" isset($dataItem['readonly'])  "}  readonly disabled="disabled"  {/if}
                            {if condition="$val eq $dataItem[4]"} checked="" {/if}
                            {in name="$val" value="$dataItem[4]"} checked="" {/in}
                            value="{$val}" title="{$key}">
                            {/foreach}
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[5]}</div>
                    </div>
                </case>
                <case value="select">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-inline">
                            <select  lay-filter="{$dataItem[0]}"
                                     <if condition=" !isset($dataItem['readonly'])  "> name="{$dataItem[0]}"  </if>
                            >
                            <foreach name="dataItem.3" item="val" key="key">
                                <option value="{$val}"
                                    <if condition=" isset($dataItem['readonly'])  "> readonly disabled="disabled" </if>
                                    <if condition="$val eq $dataItem[4]"> selected="" </if>
                                    <if condition=" isset($dataItem['noReadonly']) and !in_array($val,$dataItem['noReadonly'])">
                                        readonly disabled="disabled"
                                    </if>
                                >{$key}</option>
                            </foreach>
                            </select>
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[5]}</div>
                    </div>
                </case>
                <case value="select_group">
                    <div class="layui-form-item select_group{$dataItem[0]}">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        {php} $i=0;{/php}
                        {foreach $dataItem[3]["list"] as $defval=>$selectItem }
                        {php} $i++;{/php}

                        {if condition="$i elt $dataItem[3]['max_level'] "}{// 最大等级}
                        <div class="layui-input-inline">
                            <select  {if condition=" !isset($dataItem['readonly'])  "}  name="{$dataItem[0]}"  {/if}
                            lay-filter="{$dataItem[0]}">
                            {foreach $selectItem as $key=>$val }
                            <option  {if condition=" isset($dataItem['readonly'])  "}   readonly disabled="disabled" {/if}
                            value="{$val}" {if condition="$val eq $defval"} selected=""  {/if}
                            >{$key}</option>
                            {/foreach}
                            </select>
                        </div>
                        {/if}
                        {/foreach}
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                    </div>
                </case>
                <case value="radio">
                    <div class="layui-form-item"
                         {if condition=" isset($dataItem['readonly'])  "}   lay-filter="readonlyInput" {/if}
                    >
                    <label class="layui-form-label">{$dataItem[1]}</label>
                    <div class="layui-input-block" {if condition=" isset($dataItem['readonly'])  "}   readonly disabled="disabled" {/if} >
                        <foreach  name = 'dataItem.3' item="val" key="key">
                            <input type="radio"   value="{$val}" name="{$dataItem[0]}"
                                <if condition=" isset($dataItem['readonly'])  ">   readonly disabled="disabled" </if>
                                <if condition="$val eq $dataItem[4]"> checked="" </if>
                                title="{$key}" >
                        </foreach>
                    </div>
                    <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[5]}</div>
                    </div>
                </case>
                <case value="textarea">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div class="layui-input-block" >
                            <textarea placeholder="请输入内容" class="layui-textarea"
                                <if condition=" !isset($dataItem['readonly'])  ">  name="{$dataItem[0]}" </if>
                                <if condition=" isset($dataItem['readonly'])  "> readonly disabled="disabled" </if>
                            >{$dataItem[3]}</textarea>
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                    </div>
                </case>
                <case value="baidu">
                    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
                    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
                    <script type="text/javascript">
                        //编辑器路径定义
                        var editorURL = GV.WEB_ROOT;
                    </script>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">{$dataItem[1]}</label>
                        <div >
                            <if condition=" !isset($dataItem['readonly'])  ">
                                <script type="text/plain"name="{$dataItem[0]}"
                                        id="content">
                                    {$dataItem[3]}
                                </script>
                            </if>
                            <if condition=" isset($dataItem['readonly'])  ">{$dataItem[3]}</if>
                        </div>
                        <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                    </div>
                </case>
                <case value="hidden">
                    <input type="hidden" name="{$dataItem[0]}" value="{$dataItem[3]}">
                </case>
                <case  value="password">
                    <div class="layui-form-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$dataItem[1]}</label>
                            <div class="layui-input-inline">
                                <input type="password" autocomplete=""
                                       {if condition=" !isset($dataItem['readonly'])  "}  name="{$dataItem[0]}"  {/if}
                                {if condition=" isset($dataItem['readonly'])  "} readonly disabled="disabled" {/if}
                                value="{$dataItem[3]}"  class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                        </div>
                    </div>
                </case>
                <case value="text" >
                    <div class="layui-form-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$dataItem[1]}</label>
                            <div class="layui-input-inline">
                                <input type="text" autocomplete=""
                                       <if condition=" !isset($dataItem['readonly'])  ">  name="{$dataItem[0]}" </if>
                                        <if condition=" isset($dataItem['readonly'])  "> readonly disabled="disabled"</if>
                                value="{$dataItem[3]}"  class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                        </div>
                    </div>
                </case>

                <case value = 'multiMap'>
                    <script type="text/html" id="photos-item-tpl">
                        <li id="saved-image{id}">
                            <input id="photo-{id}" type="hidden"  value="{filepath}">
                            <input class="form-control" id="photo-{id}-name"  type="hidden" name="{$dataItem[0]}" value="{name}"
                                   style="width: 200px;" title="图片名称">
                            <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
                                 onclick="imagePreviewDialog(this.src);">
                            <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
                            <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
                        </li>
                    </script>
                    <div class="layui-form-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$dataItem[1]}</label>
                            <div class="layui-input-inline">
                                <ul id="photos" class="pic-list list-unstyled form-inline"></ul>
                                <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                                   class="btn btn-default btn-sm">选择图片</a>
                            </div>
                            <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                        </div>
                    </div>
                </case>

                <case value="image">
                    <script type="text/html" id="files-item-tpl">
                        <li id="saved-file{id}">
                            <input id="file-{id}" type="hidden"  value="{filepath}">
                            <input class="form-control" id="file-{id}-name" type="text" name="{$dataItem[0]}" value="{name}"
                                   style="width: 200px;" title="文件名称">
                            <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
                            <a href="javascript:uploadOne('图片上传','#file-{id}','file');">替换</a>
                            <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
                        </li>
                    </script>
                    <div class="layui-form-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$dataItem[1]}</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="{$dataItem[0]}" id="thumbnail" value="">
                                <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                    <img src="__TMPL__{$dataItem[3]}"
                                         id="thumbnail-preview"
                                         width="135" style="cursor: pointer"/>
                                </a>
                                <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                            </div>
                            <div class="layui-form-mid layui-word-aux remark_{$dataItem[0]}">{$dataItem[4]}</div>
                        </div>
                    </div>
                </case>
            </switch>
        </foreach>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <div id="layui-xtree-demo1"></div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    $(function () {
        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        editorcontent.render('content1');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
</script>
<script>
    layui.use(['form', 'layedit', 'laydate','upload'], function() {
        var form = layui.form(),
            layer = layui.layer,
            laydate = layui.laydate;
        var $ = layui.jquery;
        form.render();
    });
</script>
</body>
<block name="foot"></block>
</html>